import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from 'path';//这个插件要单独安装


export default defineConfig(({command}) => {
    //const isBuild = command === 'build';
    const alias = {
        //'@/': resolve('src') + '/'
        '@/': resolve(__dirname, 'src') + '/'
    };
    const server = {
        open: true, //自动浏览
        port: 8088, //启动端口
        proxy: {
            '/api': {
                target: 'http://localhost:8081',//后端服务器端口号
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
            },
        }
    };
    const plugins = [vue()];
    return {
        resolve: {alias},
        plugins,
        server
    }
})
